package com.king.io;

import java.io.*;
import java.util.List;

import com.google.common.io.ByteStreams;
import com.google.common.io.CharStreams;
import com.google.common.io.LineReader;

/**
 * @author taomk
 * @version 1.0
 * @since 15-3-10 下午5:02
 */
public class CharStreamsTest {

	public static void main(String [] args) throws IOException {
		FileReader reader = new FileReader("abc.properties");
		List<String> lines = CharStreams.readLines(reader);

		String content = CharStreams.toString(reader);

		LineReader lineReader = new LineReader(reader);
		for (String line = lineReader.readLine(); line != null; line = lineReader.readLine()) {
			System.out.println(line);
		}

		FileWriter writer = new FileWriter("cba.properties");
		CharStreams.copy(reader, writer);

		FileInputStream inputStream = new FileInputStream("abc.properties");
		byte[] contents = ByteStreams.toByteArray(inputStream);

		FileOutputStream outputStream = new FileOutputStream("cba.properties");
		ByteStreams.copy(inputStream, outputStream);
	}
}
